package com.example.myapplication;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.annotation.RequiresApi;

import com.sanstar.baiduFacePay.BaiduFacePay;
import com.sanstar.baiduFacePay.callback.IBaiduFaceCB;
import com.sanstar.baiduFacePay.utils.BitmapUtils;

import java.util.Base64;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class AddFaceActivity extends Activity {
    public static final String TAG = "AddFaceActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_face);

        Button bt = findViewById(R.id.bt);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startLoadImage();
            }
        });
    }

    private void startLoadImage() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("pictureURL", "sdcard/123.jpg");
        BaiduFacePay.getInstance().getFaceFeature(map, new IBaiduFaceCB() {
            @RequiresApi(api = Build.VERSION_CODES.O)
            @Override
            public void response(Map map) {
                String msg = (String) map.get("return_msg");
                int code = (int) map.get("return_code");
                byte[] feature = (byte[]) map.get("feature");
                Log.d(TAG, "get feature msg = " + msg + ", code = " + code);
                Log.d(TAG, "feature = " + Base64.getEncoder().encodeToString(feature));
            }
        });


    }
}
